package server.layer;

/**
 * Created by IntelliJ IDEA.
 * User: Awake
 * Date: 23.04.12
 * Time: 2:35
 * To change this template use File | Settings | File Templates.
 */
public enum ServiceProtocol {
    CONNECT(".conn"),
    CLOSE_CONNECTION(".bye"),

    ADD_PERSON(".add_person"),
    DELETE_PERSON(".delete_person"),
    UPDATE_LIST(".update_list"),                     //Receive all list with basic data
    UPDATE_PERSON(".update_field"),                 //Update only fields from table
    UPDATE_DESCRIPTION(".update_description"),
    UPDATE_IMAGE(".update_image"),
    UPDATE_PHONES(".update_phones"),
    UPDATE_ADDRESS(".update_address"),

    GET_DESCRIPTION(".get_description"),            //Receiving all additional information
    GET_FILE(".get_file");


    private ServiceProtocol(String abbr) {
        this.abbr = abbr;
    }

    public String getAbbr() {
        return abbr;
    }

    static public ServiceProtocol getCommand(String str) {
        for (ServiceProtocol sc : ServiceProtocol.values()) {
            if (sc.getAbbr().equals(str)) {
                return sc;
            }
        }
        throw new RuntimeException("unknown type");
    }

    private String abbr;
}